/**
 * Resourece
 * @ 第一屏 杂项
 */
import { Base } from "@/pixi/base";
class Resourece extends Base {
  Resourece: any[];
  getSprites: any;
  isRendering: boolean;
  position: object | string;
  anchor: object | string;
  constructor() {
    super();
    this.Resourece = [];
    this.getSprites = {};
    this.load();
    this.position = {x: 0, y: 0};
    this.anchor = "center";
    this.isRendering = true
  }
  load() {
    // 遍历资源
    const ResoureceNameList: string[] = [
      "p1bg",
      "p1-cloud1",
      // "p1-cloud2",
      "p1-grass1",
      // "p1-grass2",
      "p1-house",
      "p1-p1",
      "p1-star",
      "p1-tree",
    ];
    console.log(ResoureceNameList)
    for (let i = 0; i < ResoureceNameList.length; i++) {
      this.Resourece.push({
        name: `${ResoureceNameList[i].replace("-", "")}`,
        url: require(`@/${this.baseUrl}/images/${ResoureceNameList[i]}.png`),
      });
    }
    // 设置精灵
    for (let i = 0; i <= ResoureceNameList.length - 1; i++) {
      console.log(ResoureceNameList[i].replace("-", ""));
      this.getSprites[ResoureceNameList[i].replace("-", "")] = {
        key: `${ResoureceNameList[i].replace("-", "")}`,
        size: { mode: "widthFit", width: 0.5 },
        position: "center",
        anchor: "center",
        alpha: '1',
      };
    }

    this.getSprites.p1bg = {
      key: `p1bg`,
      size: {mode: "heightFit", height: 1  },
      position:  {x:1.2, y: .5},
      anchor: "center",
      alpha: '1',
    };
    this.getSprites.p1cloud1 = {
      key: `p1cloud1`,
      size: { mode: "widthFit", width: 1.2 },
      position: { 
        x:.5, y: .2
      },
      anchor: "center",
      alpha: '1',
    };
    this.getSprites.p1grass1 = {
      key: `p1grass1`,
      size: { mode: "widthFit", width: 1.2 },
      position: { 
        x:.5, y: 1.05
      },
      anchor: "bottom",
      alpha: '1',
    };
    // this.getSprites.p1grass2 = {
    //   key: `p1grass2`,
    //   size: { mode: "widthFit", width: 1 },
    //   position: { 
    //     x:1.5, y: 1.05
    //   },
    //   anchor: "bottom",
    // };
    this.getSprites.p1tree = {
      key: `p1tree`,
      size: { mode: "widthFit", width: .5 },
      position: { 
        x:.3, y: 1.1
      },
      anchor: "bottom",
      alpha: '1',
    };
    this.getSprites.p1star = {
      key: `p1star`,
      size: { mode: "widthFit", width: .05 },
      position: { 
        x:.5, y: .3
      },
      anchor: "center",
      alpha: "0"
    };
    this.getSprites.p1house = {
      key: `p1house`,
      size: { mode: "widthFit", width: 2.1 },
      position: { 
        x:2, y: 0
      },
      anchor: "top",
      alpha: '1',
    };
    this.getSprites.p1p1 = {
      key: `p1p1`,
      size: { mode: "widthFit", width: .6 },
      position: { 
        x:1.5, y: 1.03
      },
      anchor: "bottom",
      alpha: '1',
    };
  }
}
export default new Resourece();
